Skip to content

feat(remix): Server Timing Headers Trace Propagation PoC#18653

Open
onurtemizkan wants to merge 21 commits intodevelopfrom
onur/remix-server-timing-headers
Open

feat(remix): Server Timing Headers Trace Propagation PoC#18653
onurtemizkan wants to merge 21 commits intodevelopfrom
onur/remix-server-timing-headers

Conversation

@onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Jan 1, 2026

Adds automatic trace propagation from server to client via the Server-Timing HTTP header for Remix applications.

This provides an alternative to meta tag injection for linking server and client traces. The server automatically injects sentry-trace and baggage into the Server-Timing response header, and the client SDK reads it via the Performance API during pageload.

Server-side:

  • generateSentryServerTimingHeader() - generates the header value
  • addSentryServerTimingHeader(response) - adds header to a Response
  • Automatic injection in document request handler
  • Cloudflare apps require manual response wrapping in entry.server.tsx using addSentryServerTimingHeader

Client-side:

  • Reads Server-Timing from navigation timing entries
  • Falls back to meta tags if Server-Timing unavailable
  • Async retry mechanism for slow header processing

Works on both Node.js and Cloudflare Workers environments.

Closes #18696 (added automatically)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a proof-of-concept for propagating Sentry trace context from server to client using the Server-Timing HTTP header and the browser Performance API. This provides an alternative to meta tag-based trace propagation, particularly useful for streaming SSR responses and edge runtimes.

Key changes:

  • Added utilities for generating and injecting Server-Timing headers with Sentry trace data
  • Implemented client-side parsing of Server-Timing headers via the Performance API
  • Updated server instrumentation to capture and propagate trace context via Server-Timing headers
  • Added comprehensive E2E test coverage for both Node.js and Cloudflare environments

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
packages/remix/src/server/serverTimingTracePropagation.ts New utility module for generating Server-Timing headers with trace context
packages/remix/src/client/serverTimingTracePropagation.ts New client-side utilities for parsing trace data from Server-Timing headers
packages/remix/src/server/instrumentServer.ts Updated server instrumentation to inject Server-Timing headers and refactored trace propagation logic
packages/remix/src/client/performance.tsx Updated pageload span initialization to use Server-Timing trace propagation
packages/remix/src/server/index.ts Exported new Server-Timing utilities for public API
packages/remix/src/client/index.ts Exported new client-side Server-Timing utilities
packages/remix/src/cloudflare/index.ts Exported Server-Timing utilities for Cloudflare runtime
dev-packages/e2e-tests/test-applications/remix-server-timing/* New E2E test application validating Server-Timing trace propagation
dev-packages/e2e-tests/test-applications/remix-hydrogen/* Updated Hydrogen test app to demonstrate Cloudflare support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@onurtemizkan onurtemizkan force-pushed the onur/remix-server-timing-headers branch 4 times, most recently from 1f07bc8 to 67ec468 Compare January 2, 2026 15:42
@onurtemizkan onurtemizkan marked this pull request as ready for review January 5, 2026 12:55
@onurtemizkan onurtemizkan force-pushed the onur/remix-server-timing-headers branch from 3e06c9b to 48e03dd Compare January 5, 2026 12:55
@onurtemizkan onurtemizkan force-pushed the onur/remix-server-timing-headers branch from d882ca3 to 982c420 Compare January 5, 2026 15:31
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,890 - 8,520 +4%
GET With Sentry 1,700 19% 1,591 +7%
GET With Sentry (error only) 6,035 68% 5,784 +4%
POST Baseline 1,221 - 1,106 +10%
POST With Sentry 595 49% 529 +12%
POST With Sentry (error only) 977 80% 996 -2%
MYSQL Baseline 3,252 - 3,197 +2%
MYSQL With Sentry 493 15% 382 +29%
MYSQL With Sentry (error only) 2,666 82% 2,570 +4%

View base workflow run

@onurtemizkan onurtemizkan force-pushed the onur/remix-server-timing-headers branch from 1b1481d to 8a43e90 Compare January 8, 2026 09:25
@onurtemizkan onurtemizkan force-pushed the onur/remix-server-timing-headers branch from fa61b3c to 7518ec6 Compare January 23, 2026 14:35
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onurtemizkan sorry for the delay on this! I merged in #18673 to get support for server-timing trace continuation on the client side in the general browser SDK. Could you update the PR to use this instead of the remix-specific approach? The server side looks fine to me, though I'll give this a more proper look once the PR is updated.

@onurtemizkan onurtemizkan force-pushed the onur/remix-server-timing-headers branch from 7518ec6 to 1f7c85c Compare February 2, 2026 13:59
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Codecov Results 📊


Generated by Codecov Action

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(remix): Server Timing Headers Trace Propagation PoC

2 participants